home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Think Class Libraries / WASTE TCL 1.8 / WASTE TCL 1.8 ƒ / CWASTEText.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-12  |  9.1 KB  |  299 lines  |  [TEXT/MMCC]

  1. /********************************************************\
  2.  CWASTEText.h
  3.  
  4.     by Dan Crevier
  5.     version 1.8
  6.  
  7.     Roms    95/11/08    adapted to THINK C / TCL 1.1.3
  8. \********************************************************/
  9.  
  10. #pragma once
  11.  
  12. #include "CAbstractText.h"
  13. #include "WASTE.h"
  14. class CPrinter;
  15. class CWASTEText;
  16.  
  17. // better define of WASTE version
  18. #ifndef WASTE_VERSION
  19.     #ifdef WASTE11
  20.         #define WASTE_VERSION    0x01100000
  21.     #else
  22.         #define WASTE_VERSION    0x01000000
  23.     #endif
  24. #endif
  25.  
  26. // #define WASTE_OBJECT_ARCHIVE to 1 if you want to use the WASTE Object Archive
  27. // If it's 0 and WASTE_OBJECTS is 1, WASTE-TCL will use its own handlers
  28. // only supported with WASTE 1.1
  29. #ifndef WASTE_OBJECT_ARCHIVE
  30. #define WASTE_OBJECT_ARCHIVE    0
  31. #endif
  32.  
  33. // #define WASTE_TABS to 1 if you are using the WETabs tab code
  34. // only supported with WASTE 1.1
  35. #ifndef WASTE_TABS
  36. #define WASTE_TABS    0
  37. #endif
  38.  
  39. // #define WASTE_AUTO_TABS to 1 if you want CWASTEText objects to
  40. // automatically have each instance support tabs
  41. // only supported with WASTE 1.1
  42. #ifndef WASTE_AUTO_TABS
  43. #define WASTE_AUTO_TABS    1
  44. #endif
  45.  
  46. // #define WASTE_OBJECTS as it's #defined for the compilation of WASTE
  47. // If it's 0, none of the object code will be included
  48. // only supported with WASTE 1.1
  49. #ifndef WASTE_OBJECTS
  50. #define WASTE_OBJECTS    1
  51. #endif
  52. #if WASTE_VERSION == 0x01000000
  53. #define WASTE_OBJECTS    0
  54. #endif
  55.  
  56. #ifdef THINK_C
  57. #define cmdBlack    11420L
  58. #define cmdRed        11421L
  59. #define cmdGreen    11422L
  60. #define cmdBlue        11423L
  61. #define cmdCyan        11424L
  62. #define cmdMagenta    11425L
  63. #define cmdYellow    11426L
  64. #else
  65. long  const cmdBlack=11420;
  66. long  const cmdRed=11421;
  67. long  const cmdGreen=11422;
  68. long  const cmdBlue=11423;
  69. long  const cmdCyan=11424;
  70. long  const cmdMagenta=11425;
  71. long  const cmdYellow=11426;
  72. #endif    // THINK_C
  73.  
  74. class CWASTEText : public CAbstractText
  75. {
  76.     public:
  77.         
  78. #if TCL_VERSION >= 0x02000000
  79.         TCL_DECLARE_CLASS
  80. #endif
  81.         
  82.         // data members
  83.         WEHandle     macWE;            // handle to WE data
  84.         long        spacingCmd;        // Line spacing command number
  85.         long        alignCmd;        // alignment cmd number
  86.         long        printPageWidth;
  87.         CPrinter    *itsPrinter;
  88.             
  89.         // construction/destruction
  90.         
  91. #ifndef THINK_C
  92.         CWASTEText();
  93.         CWASTEText(CView *anEnclosure, CBureaucrat *aSupervisor,
  94.             short aWidth = 0, short aHeight = 0, short aHEncl = 0,
  95.             short aVEncl = 0, SizingOption aHSizing = sizELASTIC,
  96.             SizingOption aVSizing = sizELASTIC, short aLineWidth = -1,
  97.             Boolean aScrollHoriz = FALSE, TextStyle *tStyle = NULL,
  98.             Boolean supportObjects = true, Boolean supportUndo = true,
  99.             Boolean supportDragAndDrop = true, Boolean outlineHighliting = true,
  100.             Boolean drawOffscreen = false);
  101.         
  102.         virtual ~CWASTEText();
  103. #else
  104.         virtual void    Dispose(void);
  105. #endif    // THINK_C
  106.  
  107.         void IWASTEText(CView *anEnclosure, CBureaucrat *aSupervisor,
  108.             short aWidth, short aHeight, short aHEncl, short aVEncl,
  109.             SizingOption aHSizing, SizingOption aVSizing,
  110.             short aLineWidth,
  111.  
  112. #ifndef THINK_C
  113.             TextStyle *tStyle = NULL,
  114.             Boolean supportObjects = true,
  115.             Boolean supportUndo = true,
  116.             Boolean supportDragAndDrop = true,
  117.             Boolean outlineHighliting = true,
  118.             Boolean drawOffscreen = false
  119. #else
  120.             TextStyle *tStyle,
  121.             Boolean supportObjects,
  122.             Boolean supportUndo,
  123.             Boolean supportDragAndDrop,
  124.             Boolean outlineHighliting,
  125.             Boolean drawOffscreen
  126. #endif    // THINK_C
  127.             );
  128.         virtual void IViewTemp(CView *anEnclosure, CBureaucrat *aSupervisor,
  129.                             Ptr viewData);
  130.  
  131. #if WASTE_VERSION >= 0x01100000
  132.         virtual void DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent);
  133.         virtual WEActionKind GetUndoInfo(Boolean *redoFlag);
  134.         virtual void DoUndo(void);
  135. #else
  136.         CTextEditTask        *MakeEditTask( long editCmd);
  137.         CTextStyleTask        *MakeStyleTask( long styleCmd);
  138. #endif
  139.  
  140. #if WASTE_TABS
  141.         virtual void        InstallTabHandlers(void);
  142. #endif
  143.  
  144.         virtual void         AdjustCursor(Point where, RgnHandle mouseRgn);
  145.  
  146. #if WASTE_VERSION >= 0x01100000
  147.         // drag and drop
  148.         void                InstallDragHandlers(void);
  149.         void                 RemoveDragHandlers(void);
  150.         virtual Boolean        DoDrag(EventRecord *theEvent, Point where);
  151. #endif
  152.  
  153.         // Menu and commands
  154.         virtual void        UpdateMenus(void);
  155.         virtual void         DoCommand(long theCommand);  //mf
  156.  
  157.         // Mouse and Keystrokes
  158.         virtual void        DoClick(Point hitPt, short modifierKeys, long when);
  159.         virtual void        PerformEditCommand(long theCommand);
  160.  
  161.         // Validation
  162.         virtual void        CheckInsertion(long numChars, long styleSize, Boolean useSelection);
  163.  
  164.         // Display
  165.         virtual void        Draw(Rect *area);
  166.         virtual void        Activate();
  167.         virtual void        Deactivate();
  168.         virtual void        SetSelection(long selStart, long selEnd, Boolean fRedraw);
  169.         Boolean                SetOutlineHighliting(Boolean hilite);
  170.         virtual void        SetTextMargin(short margin);
  171.         
  172.         // Text Specification
  173.         virtual short        GetChar(long offset);
  174.         virtual void         Clear(void);
  175.         virtual void         SetTextPtr(Ptr textPtr, long numChars);
  176.         virtual void         StopInlineSession(void);
  177.         virtual Handle     GetTextHandle(void);
  178.         virtual Handle     CopyTextRange(long start, long end);
  179.         virtual void         CopyRangeWithStyle(long start, long end, Handle hText,
  180.                                 StScrpHandle hStyles);
  181. #if WASTE_VERSION >= 0x01100000
  182.         virtual void         CopyRangeWithStyleSoup(long start, long end, Handle hText,
  183.                                 StScrpHandle hStyles, WESoupHandle hSoup);
  184. #endif
  185.         virtual void         InsertTextPtr(Ptr text, long length, Boolean fRedraw);
  186.         virtual void         InsertWithStyle(Ptr text, long length, StScrpHandle hStyles,
  187.                                 Boolean fRedraw);
  188. #if WASTE_VERSION >= 0x01100000
  189.         virtual void         InsertWithStyleSoup(Ptr text, long length, StScrpHandle hStyles,
  190.                                 WESoupHandle hSoup, Boolean fRedraw);
  191. #endif
  192.         virtual void         TypeChar(char theChar, short theModifers);
  193.         virtual void         Specify(Boolean fEditable, Boolean fSelectable,
  194.                                 Boolean fStylable);
  195.  
  196.         // Calibrating
  197.         virtual void         CalcWERects(void);
  198.         virtual void         AdjustBounds(void);
  199.         virtual void         ResizeFrame(Rect *delta);
  200.         virtual void         InhibitRecal(Boolean inhibit);
  201.         virtual void         InhibitRedraw(Boolean inhibit);
  202.  
  203.         virtual void        SetLineWidth(short aLineWidth);
  204.  
  205.         virtual long         FindLine(long charPos);
  206.         virtual long         GetLength(void);
  207.         
  208.         // Text Characteristics
  209.         virtual void        SetFontColor(RGBColor *aFontColor);        //mf
  210.         virtual void        SetFontColorAll(RGBColor *aFontColor);        //mf
  211.         virtual void         SetFontNumber(short aFontNumber);
  212.         virtual void         SetFontNumberAll(short aFontNumber);
  213.         virtual void         SetFontNameAll(Str255 aFontName);
  214.         virtual void         SetFontStyle(short aStyle);
  215.         virtual void         SetFontStyleAll(short aStyle);
  216.         virtual void         SetFontSize(short aSize);
  217.         virtual void         SetFontSizeAll(short aSize);
  218.         virtual void         SetTextMode(short aMode);
  219.         virtual void         SetAlignment(short anAlignment);
  220.         virtual void         SetAlignCmd(long alignCmd);
  221.         virtual void         SetSpacingCmd(long aSpacingCmd);
  222.         virtual void        SetTheStyleScrap(long rangeStart, long rangeEnd,
  223.                                 StScrpHandle styleScrap, Boolean redraw);
  224.         virtual void         SetStyle(short mode, TextStyle *newStyle, Boolean redraw);
  225.  
  226.         virtual long         GetHeight(long startLine, long endLine);
  227.         virtual long         GetCharOffset(LongPt *aPt);
  228.         virtual void         GetCharPoint(long offset, LongPt *aPt);
  229.         virtual void         GetTextStyle(short *whichAttributes, TextStyle *aStyle);
  230.         virtual StScrpHandle GetTextStyles(void);
  231.         virtual void         GetCharStyle(long charOffset, TextStyle *theStyle);
  232.         virtual long         GetSpacingCmd(void);
  233.         virtual long         GetAlignCmd(void);
  234.         virtual StScrpHandle GetTheStyleScrap(void);
  235. #if WASTE_VERSION >= 0x01100000
  236.         virtual WESoupHandle GetTheSoup(void);
  237. #endif
  238.         virtual void        GetRunInfo(long offset, WERunInfo *runInfo);
  239.  
  240.         virtual long         GetNumLines(void);
  241.         virtual void        GetSelection(long *selStart, long *selEnd);
  242.         virtual void         HideSelection(Boolean hide, Boolean redraw);
  243.         virtual void         GetSteps(short *hStep, short *vStep);
  244.  
  245.         // Printing
  246.         virtual void         Paginate(CPrinter *aPrinter, short pageWidth, short pageHeight);
  247.         virtual void         AboutToPrint(short *firstPage, short *lastPage);
  248.         virtual void         DonePrinting(void);
  249.  
  250. #if WASTE_VERSION >= 0x01100000
  251. #if WASTE_OBJECTS
  252.         // Pictures
  253.         virtual void         InsertPicture(PicHandle pHandle, Boolean fRedraw);
  254.  
  255.         // Sounds
  256.         virtual void         InsertSound(Handle sHandle, Boolean fRedraw);
  257.  
  258. #if WASTE_OBJECT_ARCHIVE
  259.         // Files
  260.         virtual void         InsertFSSpec(FSSpec *theFSSpec, Boolean fRedraw);
  261. #endif // WASTE_OBJECT_ARCHIVE
  262. #endif // WASTE_OBJECTS
  263. #endif // WASTE 1.1
  264.  
  265.         // Cursor
  266.         virtual void         Dawdle(long *maxSleep);
  267.  
  268.         // Object I/O
  269. #if TCL_VERSION >= 0x02000000
  270.         virtual void         PutTo(CStream& stream);
  271.         virtual void         GetFrom(CStream& stream);
  272. #endif
  273.  
  274.         static CWASTEText *curWASTEText;
  275.         static pascal void WEPostUpdate(WEHandle hWE, long fixLength, long inputAreaStart,
  276.                             long inputAreaEnd, long pinRangeStart, long pinRangeEnd);
  277.         static pascal void WEPreUpdate(WEHandle hWE);
  278.         static pascal Boolean WEClickLoop(WEHandle hWE);
  279.  
  280. #if WASTE_VERSION >= 0x01100000
  281.         Boolean                hasUndoSupport;
  282. #endif
  283.  
  284.         // temporarily changing selection to all
  285.         virtual void         TempSelectAll(void);
  286.         virtual void         RestoreSelection(void);
  287.     
  288.     protected:
  289.  
  290.         void IWASTETextX(Boolean supportObjects, Boolean supportUndo, Boolean supportDragAndDrop,
  291.             Boolean outlineHighliting, Boolean drawOffscreen);
  292.  
  293. #if WASTE_VERSION >= 0x01100000
  294.         Boolean                dragHandlersInstalled;
  295. #endif
  296.  
  297.         short                        textMargin;
  298. };
  299.